<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="icon" href="../../favicon.ico">
    <script src="./web-office-sdk-v1.1.5.umd.js"></script>

    <script>
       function bodyOnLoad(){
           var params=location.href.split("?")[1].split("&")
           var url = params[1].split("=")[1]
           var token = params[0].split("=")[1]

            var wpsEditor = window.WebOfficeSDK.config({
                url:decodeURIComponent(url), // 如果需要通过js-sdk传递token方式鉴权，则需要包含_w_tokentype=1参数
                mount: document.querySelector('.custom-mount'),
                cooperUserAttribute: {
                    isCooperUsersAvatarVisible: false, //是否显示协作用户头像
                }
            })
            
            wpsEditor.iframe.style.height=window.innerHeight+"px"

            // 首次设置token和后续刷新token都是通过调用此API
            wpsEditor.setToken({token: token})

            wpsEditor.on('fileOpen', function(data) {
                console.log(data)
            })

            wpsEditor.on('fileStatus', function(data) {
                console.log(data)
                if(data.status===1){
                    //保存成功，刷新父窗口文件
                    opener.document.querySelector("#btnSaveBodyFile").click()
                }
            })
        }
    </script>
  </head>
  <body style="margin:0px;overflow-y: hidden;" onload="bodyOnLoad()">

    <div class="custom-mount" style="height: 100%;"/>
   
  </body>
</html>
